package com.android.clinic.app.adapter;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.android.clinic.app.R;
import com.android.clinic.app.ui.search.SearchActivity;
import com.android.clinic.app.utils.Utils;

/**
 * Created by cheng on 2018/1/26.
 */
public class TopCoverAdapter extends BaseDelegateAdapter {

    private Activity activity;

    public TopCoverAdapter(Context context) {
        super(context, R.layout.item_home_cover_head);
        activity = (Activity) context;
    }

    @Override
    public int getItemCount() {
        return 1;
    }

    @Override
    protected Object setupViewHolder(@Nullable View convertView, ViewGroup parent, int typeIndex) {
        return new ViewHolder(convertView);
    }

    @Override
    protected void setupBindViewHolder(Object viewHolder, int position, int typeIndex) {
        ViewHolder holder = (ViewHolder) viewHolder;
        holder.laySearch.setOnClickListener(v -> {
            if (!Utils.isFastClick()) {
                activity.startActivity(new Intent(activity, SearchActivity.class));
            }
        });
    }

    private class ViewHolder extends BaseViewHolder {

        private LinearLayout laySearch;

        public ViewHolder(View itemView) {
            super(itemView);
            laySearch = (LinearLayout) itemView.findViewById(R.id.layout_search);
        }
    }

}
